<?php
/**
 * 
 */
namespace app\common\model;

use think\Db;

class MemberModel extends BaseModel {

    protected $table = 'member';

    public function getLoginByPassportUid($passportUid) {
        //微信登录 并且审核通过,才能登录
        return Db::name($this->table)->where('passport_uid', $passportUid)->where('status',1)->find();
    }
    
    public function getInfoById($mid){
        return Db::name($this->table)->where('id',$mid)->find();
    }
    
    public function bindWeixin($data){
        return Db::name($this->table)->update($data);
    }
    
    /**
     * 获取 自己的所有子级
     * @param number $mid
     * @return array
     */
    public function getFMemberIdsByMid($mid){
        $where = 'FIND_IN_SET('.$mid.', pid_path) ';
        return Db::name($this->table)->where($where)->column('id');
    }
    
    public function getFristMebmerIdsByPid($pid){
        return Db::name($this->table)->where('fid',$pid)->column('id');
    }
    
    public function searchMidsByKeywords($keywords){
        return  Db::name($this->table)->where('name|tel','like','%'.$keywords.'%')->column('id');
    }
    
    
    
}